##POST http://toto-info.fonbet.com/DataService.svc/CalculateCoupons HTTP/1.1
import urllib.request,urllib.parse,re,json,time
bets=[]
request = urllib.request.Request(r"http://toto-info.fonbet.com/DataService.svc/CalculateCoupons")
request.add_header("Content-Type",r"application/json; charset=UTF-8")
tm=time.time()
data = (r'{"options":{"DrawingId":751,"ExtraCoupons":["10000"],"Kind":"coupon","StartFrom":0,"Count":50,"Mask":"XX21X22X2211221"}').encode('utf-8')
print(data)
f = urllib.request.urlopen(request, data)
print(time.time()-tm)
resp=f.read().decode('utf-8')
f.close()
p=json.loads(resp)
for  row in p.get('d').get('Summary').get('CalcResult').get('DrawingResults'): bets.append([row.get('Count'),row.get('Result')])
print(time.time()-tm)


f=open('749.CSV','w', newline='',encoding='UTF-8')
writer=csv.writer(f,delimiter=';')
writer.writerows(test(300))
f.close()


